package com.zzdx.deployment.web.controller.system;

import com.zzdx.deployment.common.annotation.Log;
import com.zzdx.deployment.common.base.AjaxResult;
import com.zzdx.deployment.common.enums.BusinessType;
import com.zzdx.deployment.common.page.TableDataInfo;
import com.zzdx.deployment.common.utils.ExcelUtil;
import com.zzdx.deployment.framework.util.ShiroUtils;
import com.zzdx.deployment.framework.web.base.BaseController;
import com.zzdx.deployment.system.domain.PrdtversionUiconfigTemplate;
import com.zzdx.deployment.system.service.IPrdtversionUiconfigTemplateService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * 产品配置模板 信息操作处理
 * 
 * @author mason
 * @date 2018-12-25
 */
@Controller
@RequestMapping("/system/prdtversionUiconfigTemplate")
public class PrdtversionUiconfigTemplateController extends BaseController
{
    private String prefix = "system/prdtversionUiconfigTemplate";
	
	@Autowired
	private IPrdtversionUiconfigTemplateService prdtversionUiconfigTemplateService;
	
	@RequiresPermissions("system:prdtversionUiconfigTemplate:view")
	@GetMapping()
	public String prdtversionUiconfigTemplate()
	{
	    return prefix + "/prdtversionUiconfigTemplate";
	}
	
	/**
	 * 查询产品配置模板列表
	 */
	@RequiresPermissions("system:prdtversionUiconfigTemplate:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(PrdtversionUiconfigTemplate prdtversionUiconfigTemplate)
	{
		startPage();
        List<PrdtversionUiconfigTemplate> list = prdtversionUiconfigTemplateService.selectPrdtversionUiconfigTemplateList(prdtversionUiconfigTemplate);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出产品配置模板列表
	 */
	@RequiresPermissions("system:prdtversionUiconfigTemplate:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PrdtversionUiconfigTemplate prdtversionUiconfigTemplate)
    {
    	List<PrdtversionUiconfigTemplate> list = prdtversionUiconfigTemplateService.selectPrdtversionUiconfigTemplateList(prdtversionUiconfigTemplate);
        ExcelUtil<PrdtversionUiconfigTemplate> util = new ExcelUtil<PrdtversionUiconfigTemplate>(PrdtversionUiconfigTemplate.class);
        return util.exportExcel(list, "prdtversionUiconfigTemplate");
    }
	
	/**
	 * 新增产品配置模板
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存产品配置模板
	 */
	@RequiresPermissions("system:prdtversionUiconfigTemplate:add")
	@Log(title = "产品配置模板", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(PrdtversionUiconfigTemplate prdtversionUiconfigTemplate)
	{
		String loginName = ShiroUtils.getLoginName();
		prdtversionUiconfigTemplate.setCreateBy(loginName);
		prdtversionUiconfigTemplate.setCreateTime(new Date());
		return toAjax(prdtversionUiconfigTemplateService.insertPrdtversionUiconfigTemplate(prdtversionUiconfigTemplate));
	}

	/**
	 * 修改产品配置模板
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		PrdtversionUiconfigTemplate prdtversionUiconfigTemplate = prdtversionUiconfigTemplateService.selectPrdtversionUiconfigTemplateById(id);
		mmap.put("prdtversionUiconfigTemplate", prdtversionUiconfigTemplate);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存产品配置模板
	 */
	@RequiresPermissions("system:prdtversionUiconfigTemplate:edit")
	@Log(title = "产品配置模板", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(PrdtversionUiconfigTemplate prdtversionUiconfigTemplate)
	{
		String loginName = ShiroUtils.getLoginName();
		prdtversionUiconfigTemplate.setUpdateBy(loginName);
		prdtversionUiconfigTemplate.setUpdateTime(new Date());
		return toAjax(prdtversionUiconfigTemplateService.updatePrdtversionUiconfigTemplate(prdtversionUiconfigTemplate));
	}
	
	/**
	 * 删除产品配置模板
	 */
	@RequiresPermissions("system:prdtversionUiconfigTemplate:remove")
	@Log(title = "产品配置模板", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(prdtversionUiconfigTemplateService.deletePrdtversionUiconfigTemplateByIds(ids));
	}
	
}
